<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>读写器管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		function locationOperation(rwid){
			$.ajax({
				type:"post",
				url:"${ctx}/guobo/rw/locationOperation?id="+rwid,
				async:true,
				success: function(data){
					if(data.code == 0){
						alert(data.msg);
					}else{
						alert(data.msg);
					}
				},
				error: function(err){
					alert(err);
				}
			});
		}
		
		function dispatching(rwid){
			alert('布控'+rwid);
		}
		function cancelDispatching(rwid){
			$.ajax({
				type:"post",
				url:"${ctx}/guobo/rw/cancelDispatching?id="+rwid,
				async:true,
				success: function(data){
					if(data.code == 0){
						alert(data.msg);
					}else{
						alert(data.msg);
					}
				},
				error: function(err){
					alert(err);
				}
			});
		}
		function pauseDispatching(rwid){
			$.ajax({
				type:"post",
				url:"${ctx}/guobo/rw/pauseDispatching?id="+rwid,
				async:true,
				success: function(data){
					if(data.code == 0){
						alert(data.msg);
					}else{
						alert(data.msg);
					}
				},
				error: function(err){
					alert(err);
				}
			});
		}
		function resumeDispatching(rwid){
			$.ajax({
				type:"post",
				url:"${ctx}/guobo/rw/resumeDispatching?id="+rwid,
				async:true,
				success: function(data){
					if(data.code == 0){
						alert(data.msg);
					}else{
						alert(data.msg);
					}
				},
				error: function(err){
					alert(err);
				}
			});
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/guobo/rw/">读写器列表</a></li>
		<shiro:hasPermission name="guobo:rw:edit"><li><a href="${ctx}/guobo/rw/form">读写器添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="rw" action="${ctx}/guobo/rw/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>名称：</label>
				<form:input path="name" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<!-- <th>编码</th> -->
				<th>名称</th>
				<th>规格</th>
				<th>IP地址</th>
				<th>生产厂家</th>
				<th>展馆</th>
				<th>位置</th>
				<th>上传位置状态</th>
				<th>更新时间</th>
				<th>读写器操作</th>
				<shiro:hasPermission name="guobo:rw:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="rw">
			<tr>
				<%-- <td>
					${rw.code}
				</td> --%>
				<td><a href="${ctx}/guobo/rw/form?id=${rw.id}">
					${rw.name}
				</a></td>
				<td>
					${rw.spec}
				</td>
				<td>
					${rw.address}
				</td>
				<td>
					${rw.manufacturer}
				</td>
				<td>
					${rw.location.exhHall.name}
				</td>
				<td>
					${rw.location.name}
				</td>
				<td>
					<c:if test="${rw.dispatchStatus =='0'}">
						位置信息未上传
					</c:if>
					<c:if test="${rw.dispatchStatus =='3'}">
						上传成功未布控
					</c:if>
					<c:if test="${rw.dispatchStatus =='1'}">
						布控成功
					</c:if>
					<c:if test="${rw.dispatchStatus == '2'}">
						暂停布控
					</c:if>
					<c:if test="${rw.dispatchStatus == '4'}">
						取消布控
					</c:if>
				</td>
				<td>
					<fmt:formatDate value="${rw.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					<%-- <input id="btnDispatching" class="btn btn-inverse" type="button" value="布  控" onclick="dispatching('${rw.id}');"/>&nbsp; --%>
					<input id="locationOperation" class="btn btn-inverse" type="button" value="位置上传" onclick="locationOperation('${rw.id}');"/>&nbsp;
					<%-- <input id="btnCancelDispatching" class="btn btn-danger" type="button" value="取消布控" onclick="cancelDispatching('${rw.id}');"/>&nbsp; --%>
					<input id="btnPauseDispatching" class="btn btn-warning" type="button" value="暂停布控" onclick="pauseDispatching('${rw.id}');"/>&nbsp;
					<input id="btnResumeDispatching" class="btn btn-success" type="button" value="恢复布控" onclick="resumeDispatching('${rw.id}');"/>&nbsp;
				</td>
				<shiro:hasPermission name="guobo:rw:edit"><td>					
    				<a href="${ctx}/guobo/rw/form?id=${rw.id}">修改</a>
					<a href="${ctx}/guobo/rw/delete?id=${rw.id}" onclick="return confirmx('确认要删除该读写器吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>